﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apex.Commons.ConfigurationCenter
{
    internal static class DBConfigurationHelper
    {
        public static IDictionary<string, string> Clone(this IDictionary<string, string> dict)
        {
            IDictionary<string, string> dictionary = new Dictionary<string, string>();
            foreach (KeyValuePair<string, string> item in dict)
            {
                dictionary[item.Key] = item.Value;
            }

            return dictionary;
        }

        public static bool IsChanged(IDictionary<string, string> oldDict, IDictionary<string, string> newDict)
        {
            if (oldDict.Count != newDict.Count)
            {
                return true;
            }

            foreach (KeyValuePair<string, string> item in oldDict)
            {
                string key = item.Key;
                string value = item.Value;
                string text = newDict[key];
                if (value != text)
                {
                    return true;
                }
            }

            return false;
        }
    }
}
